LINC
UNIVERSIDADE FEDERAL DO PARÁ
FACULDADE DE ENGENHARIA DA COMPUTAÇÃO E TELECOMUNICAÇÕES
LABORATÓRIO DE INTELIGÊNCIA COMPUTACIONAL E PESQUISA OPERACIONAL

Sistema de Apoio à Decisão para Gestão em Segurança Pública: Suporte Inteligente para a Realização de Análise de Cenários e Inferências Relatório sobre a base de homicídios e latrocínios do estado do Pará.


Orientador: Ádamo Lima de Santana
Responsável: João Gabriel Lima
Financiador: PROGRAMA DE AUXÍLIO À PESQUISA PROJETOS TEMÁTICOS DA FAPESPA: VIOLÊNCIA E SEGURANÇA PÚBLICA


Resumo

Este projeto propõe o desenvolvimento e aplicação de técnicas de inteligência computacional e visualização sobre bases de dados de segurança pública, estas propiciarão ao gestor (i.e. Delegado Geral, Secretário de Segurança) um hipercubo para análise pelos diferentes fatos e dimensões do domínio em segurança pública, em particular, mas não limitado, no que concerne aos níveis de criminalidade segundo sua tipologia e motivo determinante.

Examinando a base de dados

Tipos de Ocorrências

## [1] "Homicidio"  "Latrocinio"

Distribuição do Total de Ocorrências

## Source: local data frame [2 x 2]
## 
##    Registros total
##       (fctr) (int)
## 1  Homicidio  3051
## 2 Latrocinio   132

Distribuição das Ocorrências de Homicídio de acordo com o Bairro e o Município

## Source: local data frame [12 x 5]
## Groups: Registros, Bairros [11]
## 
##    Registros             Bairros         Municípios total
##       (fctr)              (fctr)             (fctr) (int)
## 1  Homicidio        Águas Lindas         Ananindeua    35
## 2  Homicidio              CENTRO        Parauapebas    98
## 3  Homicidio              CENTRO     Rondon do Pará    34
## 4  Homicidio Distrito Industrial         Ananindeua    31
## 5  Homicidio               Guamá              Belém    65
## 6  Homicidio         Jaderlândia          Castanhal    31
## 7  Homicidio             Jurunas              Belém    45
## 8  Homicidio                Moju               Moju    55
## 9  Homicidio         Nova Marabá             Marabá    74
## 10 Homicidio          Sacramenta              Belém    31
## 11 Homicidio              Tapanã              Belém    35
## 12 Homicidio          Zona Rural São Félix do Xingu    31
## Variables not shown: nome (chr)

Distribuição das Ocorrências de Latrocínio de acordo com o Bairro e o Município

## Source: local data frame [8 x 5]
## Groups: Registros, Bairros [8]
## 
##    Registros      Bairros Municípios total                      nome
##       (fctr)       (fctr)     (fctr) (int)                     (chr)
## 1 Latrocinio Águas Lindas Ananindeua     3 Águas Lindas - Ananindeua
## 2 Latrocinio  Cidade Nova Ananindeua     3  Cidade Nova - Ananindeua
## 3 Latrocinio   Decouville   Marituba     3     Decouville - Marituba
## 4 Latrocinio      Jurunas      Belém     3           Jurunas - Belém
## 5 Latrocinio         Moju       Moju     5               Moju - Moju
## 6 Latrocinio  Nova Marabá     Marabá     3      Nova Marabá - Marabá
## 7 Latrocinio       Tapanã      Belém     5            Tapanã - Belém
## 8 Latrocinio   Zona Rural  Tailândia     6    Zona Rural - Tailândia

Análise de Ocorrências

Total de ocorrências

ocorrencias_DIA <- dados%>%
                group_by( DATA.FATO) %>%
                summarise(count = n())

#total de ocorrências.
sum(ocorrencias_DIA$count)
## [1] 3183

Média diária de ocorrências

## [1] 8.720548

Análise de Ocorrências por Dia

Dias com Mais ocorências no ano (Dobro da média)

## [1] 20  2

Horários Perigosos

ggplot( dados,aes(FX.12.HOR,fill=is.weekend(DATA_HORA_FATO)) )+
        geom_bar()+
        xlab("Horários")+ 
        theme(axis.text.x = element_text(angle = 90, hjust = 1))

Meses mais perigosos

dadosMes <- dados
dadosMes$mes <-month(dadosMes$DATA.FATO)
resumoMes <- dadosMes %>% group_by(mes) %>%summarise(total=n())  

#Primeiro Semestre
sum( resumoMes[1:6,]$total)
## [1] 1465
#Segundo Semestre
sum( resumoMes[7:12,]$total)
## [1] 1718
ggplot( resumoMes,aes(x=mes,total) )+
        geom_bar(stat="identity")+
        xlab("Meses") + geom_vline(xintercept = 6.5)

Calendário Heat Map

source("/home/stark/MEGAsync/SEGUP/calendarHeat.R")
calendarHeat(ocorrencias_DIA$DATA.FATO, ocorrencias_DIA$count, varname="Calendar Heat Map of Violence in Pará",color = "g2r")

calendarHeat(maiorMedia$DATA.FATO, maiorMedia$count, varname="Calendar Heat Map of Most Violent days in Pará",color = "g2r")

calendarHeat(menorMedia$DATA.FATO, menorMedia$count, varname="Calendar Heat Map of least Violent days in Pará",color = "g2r")

Regras

transacoes <- dados
transacoes$AISP <- NULL
transacoes$SUPC <- NULL
transacoes$IDENTIFICAÇÃO.DO.FATO <- NULL
transacoes$RUA.DO.FATO <-NULL
transacoes$ANO.FATO<-NULL
transacoes$ANO.REGISTRO<-NULL
transacoes$Mês.do.Registro<-NULL
transacoes$Data.do.Registro<-NULL
transacoes$DATA.FATO<-NULL
transacoes$DIA.SEMANA<-NULL
transacoes$HORA.FATO<-NULL
transacoes$Registros.2<-NULL
transacoes$DATA_HORA_FATO<-NULL
transacoes$DIF_FATO_REGISTO<-NULL


tr <- as(transacoes,"transactions")
#support(tr,)

summary(tr)
## transactions as itemMatrix in sparse format with
##  3183 rows (elements/itemsets/transactions) and
##  1231 columns (items) and a density of 0.01411693 
## 
## most frequent items:
##       CLASSE.DO.MOTIVO=Crimes Contra a Pessoa 
##                                          3064 
## ESPECIALIZAÇÃO.DO.FATO=Crimes Contra a Pessoa 
##                                          3052 
##                           Registros=Homicidio 
##                                          3051 
##         GRUPO.DE.OCORRÊNCIA=Homicídio Simples 
##                                          2766 
##             CAUSA.PRESUMÍVEL=Ódio ou Vingança 
##                                          2196 
##                                       (Other) 
##                                         41185 
## 
## element (itemset/transaction) length distribution:
## sizes
##   16   17   18   19 
##  155 1693 1312   23 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   16.00   17.00   17.00   17.38   18.00   19.00 
## 
## includes extended item information - examples:
##                                   labels            variables
## 1                  TIPO.DE.PROCEDIMENTO= TIPO.DE.PROCEDIMENTO
## 2                 TIPO.DE.PROCEDIMENTO=  TIPO.DE.PROCEDIMENTO
## 3 TIPO.DE.PROCEDIMENTO=Auto de Apreensão TIPO.DE.PROCEDIMENTO
##              levels
## 1                  
## 2                  
## 3 Auto de Apreensão
## 
## includes extended transaction information - examples:
##   transactionID
## 1             1
## 2             2
## 3             3
itemFrequencyPlot(tr, support = 0.5, cex.names=0.5)

rules <- apriori(tr, parameter= list(supp=0.1, conf=0.5))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport support minlen maxlen
##         0.5    0.1    1 none FALSE            TRUE     0.1      1     10
##  target   ext
##   rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 318 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[1228 item(s), 3183 transaction(s)] done [0.00s].
## sorting and recoding items ... [28 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 5 6 7 8 9 done [0.01s].
## writing ... [10723 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
tab <-as(rules, "data.frame")
DT::datatable(tab)

Belém

belem <- dados$DISTRITO == "Belém"                
dadosBelem <- dados[belem,]

endComp <- paste( dados$RUA.DO.FATO," - ",dados$DISTRITO,",",dados$Bairros, ", Pará" ,sep = "")
dadosBelem$endereco <- endComp
gcs <- geocode(dadosBelem$endereco)

dadosBelem$lon <- gcs$lon
dadosBelem$lat <- gcs$lat

semGPS <-is.na(dadosBelem$lon)
 

#[1] "Diogo Móia, Rua - de 1158/1159 ao fim - Belém,Fátima, Pará"         
#[2] "Três de Maio, Travessa - até 1531 - lado ímpar - Belém,Fátima, Pará"
#[3] "Lameira Bittencourt, Rua - Belém,Benguí, Pará"                      
#[4] "São Clemente, Rua - até km 1,000 - Belém,Benguí, Pará"              
#[5] "Rod. dos Trabalhadores - Belém,Benguí, Pará"                        
#[6] "Alegre, Passagem (Da Passagem Augusto Lobato) - Belém,Benguí, Pará" 
#[7] "São Clemente, Rua - até km 1,000 - Belém,Benguí, Pará"              
#[8] "São Clemente, Rua - até km 1,000 - Belém,Benguí, Pará" 


novosEnd <- c(  "Rua Diogo Móia, Belém, Pará"      ,   
         "Travessa Três de Maio, Belém, Pará",
         "Rua Lameira Bittencourt  - Belém, Pará"   ,                   
         "Rua São Clemente, Rua  - Belém, Pará"   ,           
         "Rod. dos Trabalhadores - Belém, Pará"  ,                      
         "Passagem Alegre - Belém, Pará" ,
        "Rua São Clemente, Rua  - Belém, Pará" ,                           
        "Rua São Clemente, Rua  - Belém, Pará"         
        )


dadosBelem[semGPS,]$endereco <- novosEnd

gcsNovos <- geocode(novosEnd)

dadosBelem[semGPS,]$lat <- gcsNovos$lat
dadosBelem[semGPS,]$lon <- gcsNovos$lon

write.csv(dadosBelem,"belem.csv")
dadosBelem <- read.csv("belem.csv")
 

plotMapa <- function (x){
        mes <- dadosBelem[month(dadosBelem$DATA.FATO)==x,]
        print(paste("Mês ",x," : ",dim(mes)[1], " casos"))
        leaflet() %>%  addTiles()  %>%  addMarkers(lat=mes$lat,lng=mes$lon)
        #,   popup=mes$IDENTIFICAÇÃO.DO.FATO )         
}
 
plotMapaLatro <- function (){
        mes <- dadosBelem[(dadosBelem$Registros)=="Latrocinio",]
        print(paste(dim(mes)[1], " casos"))
        leaflet() %>%  addTiles()  %>%  addMarkers(lat=mes$lat,lng=mes$lon)
        #,   popup=mes$IDENTIFICAÇÃO.DO.FATO )         
}

Meses mais perigosos

dadosMes <- dadosBelem
dadosMes$mes <-month(dadosMes$DATA.FATO)
resumoMes <- dadosMes %>% group_by(mes) %>%summarise(total=n())  

#Primeiro Semestre
sum( resumoMes[1:6,]$total)
## [1] 253
#Segundo Semestre
sum( resumoMes[7:12,]$total)
## [1] 285
ggplot( resumoMes,aes(x=mes,total) )+
        geom_bar(stat="identity")+
        xlab("Meses") + geom_vline(xintercept = 6.5)

plotMapa(10)
## [1] "Mês  10  :  57  casos"

plotMapa(12)
## [1] "Mês  12  :  55  casos"

#latrocínios Belém
plotMapaLatro()
## [1] "28  casos"

Bairros Com Mais Ocorrências

limiar <- 20
ocorrencias <- dadosBelem%>%
                group_by(Registros,Bairros,Municípios)%>%
                summarise(total=n() )
 
ocorrencias$nome <- paste( ocorrencias$Bairros,"-",ocorrencias$Municípios )

homicidios <- ocorrencias%>%
               filter(total>limiar)%>%
                arrange(desc(total))




ggplot(homicidios, aes(nome,total , fill=Registros  ) )+
        geom_bar(stat="identity")+
        xlab("Bairros")+ylab("Quantidade")+ theme(axis.text.x = element_text(angle = 90, hjust = 1))

latrocinio <- ocorrencias%>%
                filter(Registros=="Latrocinio")%>%
                arrange(desc(total))

latrocinio
## Source: local data frame [17 x 5]
## Groups: Registros, Bairros [17]
## 
##     Registros           Bairros Municípios total                      nome
##        (fctr)            (fctr)     (fctr) (int)                     (chr)
## 1  Latrocinio          Barreiro      Belém     2          Barreiro - Belém
## 2  Latrocinio            Benguí      Belém     1            Benguí - Belém
## 3  Latrocinio         Cabanagem      Belém     2         Cabanagem - Belém
## 4  Latrocinio      Cidade Velha      Belém     1      Cidade Velha - Belém
## 5  Latrocinio          Cremação      Belém     1          Cremação - Belém
## 6  Latrocinio             Guamá      Belém     2             Guamá - Belém
## 7  Latrocinio           Jurunas      Belém     3           Jurunas - Belém
## 8  Latrocinio        Mangueirão      Belém     1        Mangueirão - Belém
## 9  Latrocinio      Maracangalha      Belém     2      Maracangalha - Belém
## 10 Latrocinio         Marambaia      Belém     1         Marambaia - Belém
## 11 Latrocinio             Marco      Belém     1             Marco - Belém
## 12 Latrocinio          Pedreira      Belém     1          Pedreira - Belém
## 13 Latrocinio        Sacramenta      Belém     2        Sacramenta - Belém
## 14 Latrocinio          São Brás      Belém     1          São Brás - Belém
## 15 Latrocinio            Tapanã      Belém     5            Tapanã - Belém
## 16 Latrocinio Telégrafo Sem Fio      Belém     1 Telégrafo Sem Fio - Belém
## 17 Latrocinio       Val-de-Cães      Belém     1       Val-de-Cães - Belém
ggplot(latrocinio, aes(nome,total , fill=Registros) ) +
        geom_bar(stat="identity")+
        xlab("Bairros")+ylab("Quantidade")+ theme(axis.text.x = element_text(angle = 90, hjust = 1))

Resumo da Base

summary(dados)
##               TIPO.DE.PROCEDIMENTO
##  Inquérito por Portaria :1076     
##  Inquérito por Flagrante: 226     
##  Auto de Apreensão      :  25     
##                         :  22     
##  Auto de Investigação   :  13     
##  (Other)                :   3     
##  NA's                   :1818     
##                                  UNIDADE.DE.ORIGEM
##  Del.Cr.Violentos - Hosp.Metropolitano 331: 203   
##  Parauapebas - 20ª Seccional 71           :  97   
##  Marambaia - Seccional 6                  :  95   
##  Marabá - Seccional 184                   :  84   
##  Del.Cr.Violentos - PSM UMARIZAL - 18     :  80   
##  Marabá - Unid. Pol.Cidade Nova 202       :  76   
##  (Other)                                  :2548   
##                          UNIDADE.RESPONSÁVEL Data.do.Registro             
##  Icoaraci - Pessoa 255             : 121     Min.   :2012-01-01 00:00:00  
##  Marabá - Unid. Pol.Cidade Nova 202: 120     1st Qu.:2012-04-10 00:00:00  
##  Cidade Nova - Pessoa 235          :  97     Median :2012-07-17 00:00:00  
##  Parauapebas - 20ª Seccional 71    :  93     Mean   :2012-07-12 02:47:23  
##  Sacramenta - Pessoa 239           :  78     3rd Qu.:2012-10-16 00:00:00  
##  Tailândia -  Unidade Policial 81  :  67     Max.   :2013-01-24 00:00:00  
##  (Other)                           :2607                                  
##    DATA.FATO                   DIA.SEMANA   HORA.FATO         FX.4.HOR   
##  Min.   :2012-01-01 00:00:00   DOM:834    21:00  : 134            :   1  
##  1st Qu.:2012-04-08 12:00:00   QUA:344    22:00  : 119   00 |-- 06: 806  
##  Median :2012-07-16 00:00:00   QUI:339    20:00  : 113   06 |-- 12: 513  
##  Mean   :2012-07-10 20:11:32   SAB:504    19:00  : 106   12 |-- 18: 532  
##  3rd Qu.:2012-10-14 12:00:00   SEG:479    23:00  :  98   18 |-- 24:1331  
##  Max.   :2012-12-31 00:00:00   SEX:379    3:00   :  88                   
##                                TER:304    (Other):2525                   
##      FX.12.HOR                                           CLASSE.DO.MOTIVO
##  20 |-- 22: 503   Crimes Contra a Pessoa                         :3064   
##  22 |-- 24: 428   Crimes Contra o Patrimônio                     :  83   
##  18 |-- 20: 400   Registros que não geram procedimento           :  17   
##  02 |-- 04: 319   Lei de Crimes Hediondos - Lei 8.072/1990       :  10   
##  00 |-- 02: 260   Registros não criminosos que geram procedimento:   4   
##  16 |-- 18: 228   Crimes de Violência Doméstica - Lei 11.340/2006:   3   
##  (Other)  :1045   (Other)                                        :   2   
##  Mês.do.Registro     MÊS.FATO     ANO.REGISTRO     ANO.FATO   
##  Dezembro: 328   Dezembro: 333   Min.   :2012   Min.   :2012  
##  Outubro : 314   Outubro : 309   1st Qu.:2012   1st Qu.:2012  
##  Novembro: 290   Novembro: 290   Median :2012   Median :2012  
##  Janeiro : 284   Setembro: 279   Mean   :2012   Mean   :2012  
##  Setembro: 271   Janeiro : 274   3rd Qu.:2012   3rd Qu.:2012  
##  Agosto  : 262   Maio    : 257   Max.   :2013   Max.   :2012  
##  (Other) :1434   (Other) :1441                                
##       Registros        Registros.2  
##  Homicidio :3051   Homicídio :3051  
##  Latrocinio: 132   Latrocínio: 132  
##                                     
##                                     
##                                     
##                                     
##                                     
##                               CAUSA.PRESUMÍVEL
##  Ódio ou Vingança                     :2196   
##  Outras                               : 503   
##  Ambição                              : 242   
##  Alcoolismo / Embriaguez              : 114   
##  Ciúme                                :  45   
##  Imperícia / Imprudência / Negligência:  43   
##  (Other)                              :  40   
##                            ESPECIALIZAÇÃO.DO.FATO
##  Crimes Contra a Pessoa               :3052      
##  Crimes Contra o Patrimônio           :  81      
##  Vigilância Geral                     :  21      
##  Ato Infracional (Menor)              :  12      
##  Crimes Hediondos - Lei 8.074/1990    :  10      
##  Crimes Contra a Integridade da Mulher:   5      
##  (Other)                              :   2      
##                       GRUPO.DE.OCORRÊNCIA
##  Homicídio Simples              :2766    
##  Lesão corporal seguida de morte:  71    
##  Rixa - caput                   :  23    
##  Lesão corporal grave           :  22    
##  Com causa conhecida            :  14    
##  (Other)                        :  24    
##  NA's                           : 263    
##                       SUB.GRUPO                        MEIO.EMPREGADO
##  Com participação de gang  :   7   Arma de Fogo               :2008  
##  Com valores pessoais      :   3   Arma Cortante ou Perfurante: 823  
##  Lan House                 :   2   Outros Meios               : 137  
##  Sem arrombamento          :   2   Arma Contundente           : 116  
##  Sem participação de gang  :  86   Sem Instrumento            :  81  
##  Tentado com lesão corporal:   1   Fogo                       :   5  
##  NA's                      :3082   (Other)                    :  13  
##         DISTRITO          Municípios        RISP    
##  Belém      : 538   Belém      : 663   01ªRISP:663  
##  Ananindeua : 318   Ananindeua : 318   02ªRISP:441  
##  Marabá     : 190   Marabá     : 192   10ªRISP:436  
##  Parauapebas: 100   Parauapebas: 100   03ªRISP:282  
##  Castanhal  :  97   Marituba   :  99   04ªRISP:244  
##  Icoaraci   :  84   Castanhal  :  97   09ªRISP:225  
##  (Other)    :1856   (Other)    :1714   (Other):892  
##            Regionais           Bairros          AISP        SUPC        
##  RMB            :1104   CENTRO     : 629          :1395   Mode:logical  
##  Sudeste        : 397   Zona Rural : 249   24ªAISP: 556   NA's:3183     
##  Baixo Tocantins: 244   Nova Marabá:  77   18ªAISP: 129                 
##  Salgado        : 241   Cidade Nova:  72   17ªAISP: 124                 
##  Lago de Tucuruí: 225   Guamá      :  67   22ªAISP: 124                 
##  Araguaia       : 219   Jaderlândia:  67   10ªAISP: 111                 
##  (Other)        : 753   (Other)    :2022   (Other): 744                 
##              RUA.DO.FATO                 LOCAL.DE.OCORRÊNCIA
##  Rua Principal     :1077   Via Pública             :2134    
##  Principal, Rua    : 139   Residencia Particular   : 460    
##  BR 222, Rodovia   :  33   Outros                  : 155    
##  Outras Localidades:  22   Café,Bar,Etc            : 142    
##  Rodovia PA-150    :  18   Propriedade Agropastoril: 102    
##  Estrada do Tapanã :  17   Mar, Rio, Lagoa         :  50    
##  (Other)           :1877   (Other)                 : 140    
##               IDENTIFICAÇÃO.DO.FATO DATA_HORA_FATO               
##  HOMICIDIO               : 457      Min.   :2012-01-01 00:00:00  
##  HOMICÍDIO               : 235      1st Qu.:2012-04-08 23:42:00  
##  COMUNICAÇÃO DE HOMICIDIO:  64      Median :2012-07-16 01:00:00  
##  COMUNICAÇÃO DE HOMICÍDIO:  55      Mean   :2012-07-11 09:30:40  
##  HOMICIDIO               :  40      3rd Qu.:2012-10-15 00:00:00  
##  HOMICIDIO QUALIFICADO   :  28      Max.   :2012-12-31 23:58:00  
##  (Other)                 :2304                                   
##  DIF_FATO_REGISTO
##  0      :1899    
##  1      : 855    
##  2      : 157    
##  3      :  80    
##  4      :  42    
##  5      :  27    
##  (Other): 123
summary(dados$DIF_FATO_REGISTO)
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14 
## 1899  855  157   80   42   27   19   22   10   14    7    4    4    7    2 
##   15   16   17   18   20   21   22   23   25   26   27   30   31   32   33 
##    1    2    2    2    3    1    1    1    1    2    1    1    2    1    1 
##   48   52   57   58   68   89  102  105  111  124  130  143 
##    1    1    1    1    1    1    1    1    1    1    1    1
#DIAS PARA REGISTRAR A OCORRÊNCIA
ggplot( dados,aes(DIF_FATO_REGISTO, fill=Registros) ) + geom_bar()